const LocalStorage = {
	setValue:function(key,value){
		if(value!=undefined){
			const targetValue = { data: value, format: typeof value };
			const string = JSON.stringify(targetValue);
			localStorage.setItem(key,string);
		}
	},
	getValue:function(key) {
		const value = localStorage.getItem(key);
		return value ? JSON.parse(value).data : undefined;
	},
	setValues:function(json){
		const self=this;
		for(const key in json){
			self.setValue(key,json[key]);
		}
	},
	getValues:function(keys){
		const self=this;
		keys=typeof keys=="string"? keys.split(",") : keys;
		const values={};
		for (let i=0;i<keys.length;i++){
			if(keys[i]){
				values[keys[i]]=self.getValue(keys[i]);
			}
			continue;
		}
		return values;
	},
	removeValue:function(key){
		localStorage.removeItem(key);
	},
	removeAll:function(){
		localStorage.clear();
	},
	removeFilter:function(keys){
		const self=this;
		const keyArray=typeof keys=="string"? keys.split(",") : keys;
		const filter=self.getValues(keyArray);
		self.removeAll();
		self.setValues(filter);
	},
}
export default LocalStorage;
